﻿using DailyRssDownload.Lib;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace TestDailyRssDownloadLib
{
    
    
    /// <summary>
    ///This is a test class for DateParserTest and is intended
    ///to contain all DateParserTest Unit Tests
    ///</summary>
	[TestClass()]
	public class DateParserTest {


		private TestContext testContextInstance;

		/// <summary>
		///Gets or sets the test context which provides
		///information about and functionality for the current test run.
		///</summary>
		public TestContext TestContext {
			get {
				return testContextInstance;
			}
			set {
				testContextInstance = value;
			}
		}

		#region Additional test attributes
		// 
		//You can use the following additional attributes as you write your tests:
		//
		//Use ClassInitialize to run code before running the first test in the class
		//[ClassInitialize()]
		//public static void MyClassInitialize(TestContext testContext)
		//{
		//}
		//
		//Use ClassCleanup to run code after all tests in a class have run
		//[ClassCleanup()]
		//public static void MyClassCleanup()
		//{
		//}
		//
		//Use TestInitialize to run code before running each test
		//[TestInitialize()]
		//public void MyTestInitialize()
		//{
		//}
		//
		//Use TestCleanup to run code after each test has run
		//[TestCleanup()]
		//public void MyTestCleanup()
		//{
		//}
		//
		#endregion


		/// <summary>
		///A test for ParseDateTime
		///</summary>
		[TestMethod()]
		public void ParseDateTimeTest_NoTimeZone() {
			string strUnformattedDate = "Sat Feb 16 00:00:00 2008";
			DateTime expected = new DateTime(2008, 2, 16, 0, 0, 0);
			DateTime actual;
			actual = DateParser.ParseDateTime(strUnformattedDate);
			Assert.AreEqual(expected, actual);
		}

		/// <summary>
		///A test for ParseDateTime
		///</summary>
		[TestMethod()]
		public void ParseDateTimeTest_TimeZone() {
			string strUnformattedDate = "Sat Feb 16 15:47 EST 2008";
			DateTime expected = new DateTime(2008, 2, 16, 15, 47, 0);
			DateTime actual;
			actual = DateParser.ParseDateTime(strUnformattedDate);
			Assert.AreEqual(expected, actual);
		}

		/// <summary>
		///A test for ParseDateTime
		///</summary>
		[TestMethod()]
		public void ParseDateTimeTest_WithZ() {
			string strUnformattedDate = "2008-02-12T21:05:12Z";
			// I suppose this unit test will only succeed in EST.  Probably need to mock the DateTime.Now.
			DateTime expected = new DateTime(2008, 2, 12, 16, 05, 12); 
			DateTime actual;
			actual = DateParser.ParseDateTime(strUnformattedDate);
			Assert.AreEqual(expected, actual);
		}

		/// <summary>
		///A test for ParseDateTime
		///</summary>
		[TestMethod()]
		public void ParseDateTimeTest_WithGMT() {
			string strUnformattedDate = "Sat, 16 Feb 2008 21:00:00 GMT";
			// I suppose this unit test will only succeed in EST.  Probably need to mock the DateTime.Now.
			DateTime expected = new DateTime(2008, 2, 16, 16, 00, 00); 
			DateTime actual;
			actual = DateParser.ParseDateTime(strUnformattedDate);
			Assert.AreEqual(expected, actual);
		}

	}
}
